package com.chuangjiangx.member.basic.ddd.domain.model.msg;

import com.chuangjiangx.commons.wx.msg.model.AbstractBaseData;
import com.chuangjiangx.commons.wx.msg.model.Keyword4Data;
import com.chuangjiangx.commons.wx.msg.model.MsgDataMeta;
import lombok.Data;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author cj-ch
 * @date 2018/1/31 上午11:19
 * 储值卡消费通知
 */
@Data
public class MbrCardConsumeMsg extends AbstractMbrWXMsg{
    /**
     * 标题
     *
     */
    private String title = "您好,您已成功消费.";
    /**
     * 消费时间
     */
    private Date consumeTime;
    /**
     * 消费地址
     */
    private String consumeAddress;
    /**
     * 消费金额
     */
    private BigDecimal consumeAmount;
    /**
     * 账户余额
     */
    private BigDecimal accountBalance;
    /**
     * 备注
     */
    private String remark = "感谢您的使用";

    public MbrCardConsumeMsg(Date consumeTime, String consumeAddress, BigDecimal consumeAmount, BigDecimal accountBalance) {
        this.consumeTime = consumeTime;
        this.consumeAddress = consumeAddress;
        this.consumeAmount = consumeAmount;
        this.accountBalance = accountBalance;
    }

    @Override
    public AbstractBaseData toMsgData(){

        Keyword4Data data = new Keyword4Data();
        data.setFirst(new MsgDataMeta(title));
        //获取时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        data.setKeyword1(new MsgDataMeta(format.format(consumeTime)));
        data.setKeyword2(new MsgDataMeta(consumeAddress));
        data.setKeyword3(new MsgDataMeta(String.valueOf(consumeAmount)));
        data.setKeyword4(new MsgDataMeta(String.valueOf(accountBalance)));
        data.setRemark(new MsgDataMeta(remark));
        return data;
    }

    @Override
    public WXMsg getWXMsg() {
        return WXMsg.MBR_CARD_CONSUME;
    }
}
